/*
 * 部门下拉列表
 * 参数   交易码：trancode=Dept
 * 
 */

package org.ccams.tran;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.ccams.domain.TClient;
/**
 * 部门下拉列表
 * @author alern2008@gmail.com
 * @系统名称：定制化辅助生成制造系统
 * @时间：Sep 19, 2008
 */
public class TranCustomer extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		ArrayList<TClient> al = new ArrayList<TClient>();
		List<TClient> list = getCcamsService().getTclientDao().getAllTClient();
		for(TClient t : list){
			TClient tm = new TClient();
			tm.setIdtclient(t.getIdtclient());
			tm.setCustomername(t.getCustomername());
			tm.setAccountname(t.getAccountname());			
			al.add(tm);
		}
		JSONArray JsonArray = JSONArray.fromObject(al); //得到JSON数组 
        jsonMap.put("root", JsonArray);
        json.putAll(jsonMap);
	}
}
